import pymysql

OnlineUser = "aq_local"
OnlineHost = "49.4.55.113"
OnlinePort = 33987
OnlinePassword = "rULSkzgiGsrZI0C2"
OnlineDB = "aq_data"

FIRST_USER = "root"
FIRST_PASSWORD = "123456"
FIRST_DATABASE = "aq_quantitative_home"
FIRST_HOST = "192.168.0.250"

SECOND_USER = "jiuxin_data"
SECOND_PASSWORD = "ivKtwKqPADEDT8NG"
SECOND_DATABASE = "new_data"
SECOND_HOST = "49.4.55.113"
PORT = 33987
HEADER = {
          'Accept': 'application/json, text/javascript, */*; q=0.01',
          'Accept-Encoding': 'gzip, deflate, br',
          'Accept-Language': 'zh-CN,zh;q=0.9',
          'Connection': 'keep-alive',
          'Content-Length': '400',
          'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
          'Host': 'ycjq.95358.com',
          'Origin': 'https://ycjq.95358.com',
          "Referer": "",
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
          'X-Requested-With': 'XMLHttpRequest',
          'Cookie': "",
         }

header = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
          'Accept-Encoding': 'gzip, deflate, br',
          'Accept-Language': 'zh-CN,zh;q=0.9,und;q=0.8',
          'Connection': 'keep-alive',
          'Cookie': '_xsrf=2|ccd850dc|50e0a7c310d678d3ecebacd01f8058ef|1556602814; PHPSESSID=k90vk8dhrgrgu742qkpfpi7ir1; b4f222c6b176e1891d1432d2e37baf44=1d6ec67ced2f24ebc8933faebfa3e402b8cca4dca%3A4%3A%7Bi%3A0%3Bs%3A11%3A%2215213468536%22%3Bi%3A1%3Bs%3A11%3A%2215213468536%22%3Bi%3A2%3Bi%3A2592000%3Bi%3A3%3Ba%3A6%3A%7Bs%3A2%3A%22id%22%3Bs%3A4%3A%221561%22%3Bs%3A4%3A%22name%22%3Bs%3A11%3A%2215213468536%22%3Bs%3A4%3A%22user%22%3Ba%3A1%3A%7Bs%3A6%3A%22userId%22%3Bs%3A32%3A%22c64a7408ce012833464c9a986fb52bf9%22%3B%7Ds%3A7%3A%22loginIP%22%3Bs%3A14%3A%2214.106.225.238%22%3Bs%3A13%3A%22loginPublicIp%22%3Bs%3A14%3A%2214.106.225.238%22%3Bs%3A2%3A%22ua%22%3Bs%3A115%3A%22Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F74.0.3729.131+Safari%2F537.36%22%3B%7D%7D',
          'Host': 'ycjq.95358.com',
          'Referer': 'https://ycjq.95358.com/algorithm/live/index?backtestId=2d67ee6be1065d04c449987a80b76709',
          'Upgrade-Insecure-Requests': '1',
          'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36a",
        }


backtest_header = {'Accept': 'application/json, text/javascript, */*; q=0.01',
                   'Accept-Encoding': 'gzip, deflate, br',
                   'Accept-Language': 'zh-CN,zh;q=0.9,und;q=0.8',
                   'Connection': 'keep-alive',
                   'Content-Length': '17',
                   'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                   'Cookie':  "",
                   'Host': 'ycjq.95358.com',
                   'Origin': 'https://ycjq.95358.com',
                   'Referer': "",
                   'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',
                   'X-Requested-With': 'XMLHttpRequest'
                   }

strategy_real_header = {
                    'Accept': 'application/json, text/javascript, */*; q=0.01',
                    'Accept-Encoding': 'gzip, deflate, br',
                    'Accept-Language': 'zh-CN,zh;q=0.9,und;q=0.8',
                    'Connection': 'keep-alive',
                    'Content-Length': '17',
                    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                    "Cookie": "",
                    'Host': 'ycjq.95358.com',
                    'Origin': 'https://ycjq.95358.com',
                    'Referer': "",
                    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',
                    'X-Requested-With': 'XMLHttpRequest'
                    }


def data2_connection():
    """
    连接java数据库
    :return: mysql游标
    """
    connection = pymysql.connect(host=SECOND_HOST, port=33987,
                                 user=SECOND_USER, password=SECOND_PASSWORD,
                                 db=SECOND_DATABASE, charset="utf8",
                                 cursorclass=pymysql.cursors.DictCursor)
    cursor = connection.cursor()
    return cursor, connection


def data1_connection():
    """
    连接java线上的数据库
    :return: mysql游标
    """
    connection = pymysql.connect(host=OnlineHost, port=OnlinePort,
                                 user=OnlineUser, password=OnlinePassword,
                                 db=OnlineDB, charset="utf8",
                                 cursorclass=pymysql.cursors.DictCursor, autocommit=True)
    cursor = connection.cursor()
    return cursor, connection


def test_connection():
    """
    连接java的测试的数据库
    :return:
    """
    connection = pymysql.connect(host=FIRST_HOST, port=3306,
                                 user=FIRST_USER, password=FIRST_PASSWORD,
                                 db=FIRST_DATABASE, charset="utf8",
                                 cursorclass=pymysql.cursors.DictCursor, autocommit=True)
    cursor = connection.cursor()
    return cursor, connection























